package com.zfl;

public class FindDuplicate {

    public int findDuplicate(int[] nums) {
        int slow = 0;
        int fast = 0;

        do {
            slow = nums[slow];
            fast = nums[fast];
            fast = nums[fast];
        } while (slow != fast);


        fast = 0;

        while(slow!=fast)  {

            fast=nums[fast];
            slow=nums[slow];
        }
        return slow;
    }
}
